package java8;

import java.util.function.BooleanSupplier;
import java.util.function.DoubleSupplier;
import java.util.function.IntSupplier;
import java.util.function.LongSupplier;
import java.util.function.Supplier;

public class SupplierSample {

    public static void main(String[] args) {
        // Supplier(供应者): 无入参, 须返回
        Supplier<String> strSupplier = () -> "Hello";
        // Supplier.get() 获取提供的对象
        // 输出: Hello
        System.out.println(strSupplier.get());

        // ================================================
        // IntSupplier
        // LongSupplier
        // DoubleSupplier
        // BooleanSupplier
        // ================================================
        // IntSupplier: 产生一个 int 类型值
        IntSupplier intSupplier = () -> 0;
        // LongSupplier: 产生一个 Long 类型值
        LongSupplier longSupplier = () -> 0L;
        // DoubleSupplier: 产生一个 Double 类型值
        DoubleSupplier doubleSupplier = () -> 0.;
        // BooleanSupplier: 产生一个 Boolean 类型值
        BooleanSupplier booleanSupplier = () -> Boolean.TRUE;
    }

}